import {HttpClient, HttpHeaderResponse,HttpResponse} from '@angular/common/http';
import {Injectable} from '@angular/core';
import {Observable} from "rxjs/Observable";

@Injectable()
export class InformationDetailProvider {
    public infoUrl = '/content/v1/app/one';
    public colUrl='/favorite/v1/info_favorite';

    constructor(public http: HttpClient) {
        console.log('Hello InformationDetailProvider Provider');
    }

    // 获取咨询详情
    getInfoDetail(contentId):Observable<any>{
        return this.http.get(this.infoUrl+'?contentId='+contentId+'&userRole='+localStorage.getItem('roles'))
    }

   // 收藏资讯
    collectInfo(contentId):Observable<any>{
        return this.http.post(this.colUrl+'/'+contentId,{},{responseType:'text'});
    }

    // 取消收藏
    cancelCollect(contentId):Observable<any>{
        return this.http.delete(this.colUrl+'/'+contentId,{responseType:'text'});
    }
    //分享时记录角色
    shareInfoRoles(id,userRole){
        return this.http.get('/content/v1/app/shareRecord?'+'contentId='+id+'&userRole='+userRole);
    }
}
